package com.cssy.xxkj.attach.web;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.apache.log4j.Logger;

import com.cssy.xxkj.attach.entity.AttachFileUploadDO;
import com.cssy.xxkj.attach.service.IAttachFileUploadService;
import com.cssy.xxkj.attach.util.CommConstants;

/**
 * 定时把状态为暂存的附件更改为无效
 * @author gzy
 *
 */
public class FileUploadRelatedController {

	private static final Logger logger = Logger.getLogger(FileUploadRelatedController.class);
	
	@Resource(name = "attachFileUploadService")
	private IAttachFileUploadService attachFileUploadService;
	
	public void execute(){
		
		logger.info("FileUploadRelatedController执行开始");
		
		Map<String,String> paramMap = new HashMap<String,String>();
		paramMap.put("fileRelated", CommConstants.FILE_RELATED_SAVE);
		
		List<AttachFileUploadDO> fileUploadDOs = attachFileUploadService.findAttachFileUploadDOs(paramMap);
		if(fileUploadDOs!=null&&!fileUploadDOs.isEmpty()&&fileUploadDOs.size()>0){
			for(AttachFileUploadDO fileUploadDO : fileUploadDOs){
				if(fileUploadDO==null){
					continue;
				}
				fileUploadDO.setFileRelated(CommConstants.FILE_RELATED_NO);
				attachFileUploadService.update(fileUploadDO);
			}
		}
		
		logger.info("FileUploadRelatedController执行开始结束");
	}
}
